from common.base import BasePage
from selenium.webdriver.common.by import  By




class SubmitList(BasePage):
    bt2 = (By.XPATH, '//input[@name="shipping" and @value="7"]')
    bt3 = (By.XPATH, '//input[@name="payment" and @value="1"]')
    submit = (By.XPATH, '//input[@type="image"]')
    def submitlist(self):
        # 邮政包裹
        tb=self.getElement(*self.bt2)
        if tb.is_displayed() and tb.is_enabled():
            tb.click()

        # 调整窗口
        self.driver.execute_script("window.scrollTo(0,100)")
        # 余额付款
        tb2=self.getElement(*self.bt3)
        if tb.is_displayed() and tb.is_enabled():
            tb.click()
        # 提交订单
        self.getElement(*self.submit).click()


if __name__ == '__main__':
    from pages.addShoppingList import AddShoppingList
    from pages.accountPage import AccountPage
    from pages.fristPage import FristPage
    pl = FristPage()
    pl.go_to_loginP().denglu('uroot', 'w12345678')
    add_shopping_list=AddShoppingList(pl.driver)
    pl.search()
    add_shopping_list.add_shopping_list()
    account_page = AccountPage(pl.driver)
    account_page.accountPage()
    submit_list = SubmitList(pl.driver)
    submit_list.submitlist()